<template>
  <div class="container">
      <div class="weui-cell">
        <div class="weui-cell__bd"></div>
        <div class="weui-cell__ft"><report :info="info" type="1" model="3"></report></div>
      </div>
      <div class="starInfo">
           <img :src="img+'/img_business_card_background@2x.png'" alt="" class="starInfoBg">
           <div class="starInfoC">
                <div class="originator weui-cell" v-if="info">
                    <div class="weui-cell__hd">
                        <div class="thumb">
                            <avatar 
                              :avatar="info.avatar" 
                              :Level="info.partner_level" 
                              :userId="info.id" 
                              :isAuth="info.is_auth" 
                              :isPartner="info.is_partner" 
                              v-if="info"></avatar>
                        </div>
                    </div>
                    <div class="weui-cell__bd ">
                        <div class="nickname">{{info.cert.company_name}}</div>
                        <div class="time" v-if="info.cert.introduction">{{info.user.introduction}}</div>
                        <div class="time" v-else>这个人很懒，没有填写简介</div>
                    </div>
                    <div class="weui-cell__ft">
                        <Follow :info="info" :userId="info.id" ></Follow>
                    </div>
                </div>
                <div class="adr weui-cell">
                    <div class="weui-cell__hd"><img src="/static/images/ic_location@2x.png" alt="" class="adrIcon">位置：</div>
                    <div class="weui-cell__bd">{{info.cert.company_address}}</div>
                </div>
           </div>
      </div>
      <div class="weui-cell">
          <div class="weui-cell__bd ">
               <operate :info="info" iszan="true" iscomts="true" ></operate>
          </div>
          <div class="weui-cell__bd"></div>
          <div class="weui-cell__ft share" @click="showIt"> 
              <van-icon name="share" color="#1A84FB" size="20px"/>
              <span>名片分享</span>
          </div>
      </div>
      <div class="line"></div>
      <div>
           <classTit title="用户评价"></classTit>
           <evaluate :type="1" @selCom="selCom" :Comment="Comment"></evaluate>
      </div>
      <div class="kong"></div>
      <div class="footer">
          <div class="weui-cell__bd" @click="toInfo" :data-url="'../organInfo/main?name='+info.cert.company_name+'&id='+info.id">
             <img src="/static/images/ic_introduction_mechanism@2x.png" alt="" style="height:13px;width:11px"> 机构介绍
          </div>
          <div class="weui-cell__bd" @click="toInfo" :data-url="'../organClass/main?id='+info.id">
             <img src="/static/images/ic_institutional_curriculum@2x.png" alt="" style="height:13px;width:17px"> 机构课程
          </div>
      </div>
      <saveimg :info="info" :qrcode="qrcode" v-if="share" @closeShow="closeShow" type="2" @saveImg="saveImg"></saveimg>
  </div>
</template>

<script>
import saveimg from "@/components/saveimg"
import evaluate from "@/components/evaluate";
import classTit from "@/components/classTit";
import operate from "@/components/operate"
import report from "@/components/report"
import Follow from "@/components/follow"
import avatar from "@/components/avatar"
import {startInfo} from "@/api/star"
import {otherINfo} from "@/api/other"
import {code} from "@/api/operate"
import { eva_list } from "@/api/evaluate";
export default {
  components: {
      avatar,
      evaluate,
      classTit,
      operate,
      Follow,
      report,
      saveimg,
      
  },

  data () {
    return {
      classTags:[],
      info:{},
      title:"用户评价",
      userINfo:"",
      user_id:0,
      starId:"",
      img: this.$URL.imgurl,
      share:false,
      qrcode:"",
      selComId:0,
      Comment:[],
      queS2:false,
      currentPage:1,
      load1:false
    }
  },
  methods:{
    closeShow() {
      this.share = false;
    },
     toInfo(e){
        let url=e.currentTarget.dataset.url;
        mpvue.navigateTo({url})
     },
     follow(item){
        let guan=item.guan;
        item.guan=!guan;
     },
     getComment(){
        this.queS2=false
        let data={};
        data.mp_id=this.info.id;
        data.tag_ids=this.selComId;
        data.page=this.currentPage;
        eva_list(data).then(res=>{
            if(res.code==200){ 
              let last_page=res.data.last_page;
              if(this.page==1){
                  this.Comment=res.data.data
              }else{
                  this.Comment=this.Comment.concat(res.data.data)
              }
              if(last_page>this.currentPage){
                this.load1=true
              }else{
                this.load1=false
              }
           }else if(res.code==201){
              this.queS2=true;   
           }
        })
    },
    selCom(data){
      this.selComId=data.id;
      this.Comment=[]
      this.getComment()
    },
     getInfo(){
        let data={}
        data.id=this.starId;
        data.user_id=this.user_id;
        var author;
        startInfo(data).then(res=>{
          this.info=res.data
          author=res.data.author
          console.log(author)
        }).then(res=>{
           this.getComment()
        })
     },
     saveImg() {
      this.show=false
      this.closeShow()
      console.log(this.show)
    },
      showIt() {
        let data={};
        data.user_id=this.info.id;
        data.share_type=1;
        code(data).then(res=>{
            this.qrcode=res.data;
        }).then(res=>{
          this.share = true;
        })  
        
      },
     onReachBottom(){
      if(this.load1){
        this.currentPage++
        this.getComment()
      }
    },
  },
  created () {
    
  },
  onUnload(){
     
  },
  onLoad(options){
    Object.assign(this.$data, this.$options.data())
     wx.getStorageSync("user_info")?this.user_id= wx.getStorageSync("user_info").id:'';
     this.starId=options.id;
     this.getInfo()
  }
}
</script>
<style>
.classify .nav .nav-item {
  width: 25%;
}
</style>
<style scoped lang="scss">
    .starInfo{
      width:345px;
      height:175px;
      border-radius:5px;
      margin:0 auto;
      background: #ccc;
      position: relative;
      .starInfoBg{
        width:345px;
        height:175px;
      }
      .starInfoC{
        width:345px;
        height:175px;
        position: absolute;
        top:0;
        left:0
      }
      .originator{
        padding: 30px 15px;
        padding-bottom: 25px;
      }
      .adr{
          font-size:12px;
          font-weight:500;
          color:rgba(51,51,51,1);
          line-height:18px;
          -webkit-box-align:start;
          -webkit-align-items:start;
          align-items:start;
      }
    }
    .kong{
      height: 49px;
    }
    .footer{
      width:375px;
      height:49px;
      background:rgba(255,255,255,1);
      box-shadow:0px 0px 0px 0px rgba(221,221,221,1);
      text-align: center;
      line-height: 49px;
      font-size:14px;
      font-weight:500;
      color:rgba(51,51,51,1);
      position: fixed;
      bottom: 0;
      left: 0;
      display: flex;
      border-top: 1px solid #ddd;
      img{
        vertical-align: middle;
      }
    }
    .share{
      text-align: center;
      font-size:11px;
      font-weight:500;
      color:rgba(26,132,251,1);
      line-height:18px;
      span{
        display: block;
        text-align: center;
        line-height: 1;
      }
    }
    
</style>
